package com.supplychain.scm.core.common.version.config;

import com.supplychain.scm.core.common.version.ApiWebMvcRegistrations;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author liyang
 * @version 1.0.0
 * @ClassName ApiVersionAutoConfiguration
 * @Description 接口多版本自动配置
 * @createTime 13:12:00 2023/01/05
 */
@RequiredArgsConstructor
@ConditionalOnProperty(prefix = ApiVersionProperties.PREFIX, name = "enabled", havingValue = "true")
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties({ApiVersionProperties.class})
public class ApiVersionAutoConfiguration {

    private final ApiVersionProperties apiVersionProperties;

    @Bean
    @ConditionalOnMissingBean
    public ApiWebMvcRegistrations apiWebMvcRegistrations(){
        return new ApiWebMvcRegistrations(apiVersionProperties);
    }
}
